function ColorPicker(obj){
	this.obj = obj;
	this.buildLayout();
}
ColorPicker.prototype.buildLayout = function() {
	var layout = null;
	if(!($('colorLayDiv'))){
		layout = document.createElement("div");
		layout.id='colorLayDiv';
		layout.style.cssText = "position:absolute;width:100px;height:100px;";
		layout.innerHTML = "<input style='margin:10px;width:70px;'/><br/><input type='button' value='apply color'/>";		
		document.body.appendChild(layout);	
	}
	else{
		layout=$('colorLayDiv');		
	}
	layout.childNodes[2].stopObserving('click');
	var that=this;	
	layout.childNodes[2].observe('click', function(){
		that.setColor(this);
	});
	var offset = this.obj.cumulativeOffset();
	layout.style.left=offset[0]+20+'px';
	layout.style.top=offset[1]+'px';
	layout.style.backgroundColor='#'+this.obj.getAttribute('value');
	layout.childNodes[0].value=this.obj.getAttribute('value');
	layout.show();
}
ColorPicker.prototype.setColor = function(obj1, obj2) {
	var res=obj1.previousSibling.previousSibling.value;
	this.obj.setAttribute('value',res);
	var layout=$('colorLayDiv');
	layout.style.backgroundColor='#'+res;
	layout.hide();
}